package net.togogo.egouweb1238.core.service.product.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.togogo.egouweb1238.common.page.Pagination;
import net.togogo.egouweb1238.core.dao.product.ColorDao;
import net.togogo.egouweb1238.core.domain.product.Color;
import net.togogo.egouweb1238.core.query.product.ColorQuery;
import net.togogo.egouweb1238.core.service.product.IColorService;
/**
 * 颜色
 * @author stone
 */
@Service
@Transactional
public class ColorServiceImpl implements IColorService {

	@Resource
	ColorDao colorDao;

	/**
	 * 插入数据库
	 * 
	 * @return
	 */
	public Integer addColor(Color color) {
		return colorDao.addColor(color);
	}

	/**
	 * 根据主键查找
	 */
	@Transactional(readOnly = true)
	public Color getColorById(Integer id) {
		return colorDao.getColorById(id);
	}
	
	@Transactional(readOnly = true)
	public List<Color> getColorsByIds(List<Integer> idList) {
		return colorDao.getColorsByIds(idList);
	}

	/**
	 * 根据主键删除
	 * 
	 * @return
	 */
	public Integer deleteById(Integer id) {
		return colorDao.deleteById(id);
	}

	public Integer deleteByIds(List<Integer> idList) {
		return colorDao.deleteByIds(idList);
	}

	/**
	 * 根据主键更新
	 * 
	 * @return
	 */
	public Integer updateColorById(Color color) {
		return colorDao.updateColorById(color);
	}
	
	@Transactional(readOnly = true)
	public Pagination getColorListWithPage(ColorQuery colorQuery) {
		Pagination p = new Pagination(colorQuery.getPageNo(),colorQuery.getPageSize(),colorDao.getColorListCount(colorQuery));
		p.setList(colorDao.getColorListWithPage(colorQuery));
		return p;
	}
	
	@Transactional(readOnly = true)
	public List<Color> getColorList(ColorQuery colorQuery) {
		return colorDao.getColorList(colorQuery);
	}
}
